<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/1/20
 * Time: 15:49
 */

namespace App\Http\Controllers\MiniProgramAdmin;

use App\Http\Logics\MiniProgramAdmin\PartyLogic;
use App\Http\Traits\PartyTrait;
use App\Http\Controllers\BaseController;
class PartyController extends BaseController
{
    use PartyTrait;

    /**
     * @SWG\Post(
     *     path="/party/create",
     *     tags={"Party"},
     *     description="创建活动",
     *     operationId="createParty",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="name",
     *         in="query",
     *         description="活动名称",
     *         required=true,
     *         type="string",
     *         @SWG\Items(type="string"),
     *         collectionFormat="csv"
     *     ),
     *     @SWG\Parameter(
     *         name="cover",
     *         in="query",
     *         description="活动封面",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="summary",
     *         in="query",
     *         description="活动简介",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="user_count",
     *         in="query",
     *         description="参加活动人数",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="start_date",
     *         in="query",
     *         description="活动开始日期",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="end_date",
     *         in="query",
     *         description="活动结束日期",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="start_time",
     *         in="query",
     *         description="活动开始时间",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="end_time",
     *         in="query",
     *         description="活动结束时间",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="address",
     *         in="query",
     *         description="活动地址",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="photo",
     *         in="query",
     *         description="活动联系方式",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="price",
     *         in="query",
     *         description="活动最低消费",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="party_category_id",
     *         in="query",
     *         description="活动分类ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function createParty()
    {
        $loginSession = $this->loginSession;
        $name = $this->name;
        $cover = $this->cover;
        $start_date = $this->start_date;
        $end_date = $this->end_date;
        $start_time = $this->start_time;
        $end_time = $this->end_time;
        $address = $this->address;
        $user_count = $this->user_count;
        $mobile = $this->mobile;
        $price = $this->price;
        $summary = $this->summary;
        $party_category_id = $this->party_category_id;
        $data = [
            'loginSession' => $loginSession,
            'cover' => $cover,
            'name' => $name,
            'summary' => $summary,
            'start_date' => $start_date,
            'end_date' => $end_date,
            'start_time' => $start_time,
            'end_time' => $end_time,
            'user_count' => $user_count,
            'address' => $address,
            'mobile' => $mobile,
            'price' => $price,
            'party_category_id' => $party_category_id
        ];
        $response = PartyLogic::createParty($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Post(
     *     path="/party/update",
     *     tags={"Party"},
     *     description="更新活动",
     *     operationId="updateParty",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="party_id",
     *         in="query",
     *         description="活动ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="name",
     *         in="query",
     *         description="活动名称",
     *         required=true,
     *         type="string",
     *         @SWG\Items(type="string"),
     *         collectionFormat="csv"
     *     ),
     *     @SWG\Parameter(
     *         name="cover",
     *         in="query",
     *         description="活动封面",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="summary",
     *         in="query",
     *         description="活动简介",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="user_count",
     *         in="query",
     *         description="参加活动人数",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="start_date",
     *         in="query",
     *         description="活动开始日期",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="end_date",
     *         in="query",
     *         description="活动结束日期",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="start_time",
     *         in="query",
     *         description="活动开始时间",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="end_time",
     *         in="query",
     *         description="活动结束时间",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="address",
     *         in="query",
     *         description="活动地址",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="photo",
     *         in="query",
     *         description="活动联系方式",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="price",
     *         in="query",
     *         description="活动最低消费",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="party_category_id",
     *         in="query",
     *         description="活动分类ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function updateParty()
    {
        $party_id = $this->party_id;
        $loginSession = $this->loginSession;
        $name = $this->name;
        $cover = $this->cover;
        $start_date = $this->start_date;
        $end_date = $this->end_date;
        $start_time = $this->start_time;
        $end_time = $this->end_time;
        $address = $this->address;
        $user_count = $this->user_count;
        $mobile = $this->mobile;
        $price = $this->price;
        $summary = $this->summary;
        $party_category_id = $this->party_category_id;
        $data = [
            'party_id' => $party_id,
            'loginSession' => $loginSession,
            'cover' => $cover,
            'name' => $name,
            'summary' => $summary,
            'start_date' => $start_date,
            'end_date' => $end_date,
            'start_time' => $start_time,
            'end_time' => $end_time,
            'user_count' => $user_count,
            'address' => $address,
            'mobile' => $mobile,
            'price' => $price,
            'party_category_id' => $party_category_id
        ];
        $response = PartyLogic::updateParty($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/party/normalList",
     *     tags={"Party"},
     *     description="获取活动普通列表",
     *     operationId="getPartyNormalList",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="秘钥验证",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="key",
     *         in="query",
     *         description="合作者key",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="key",
     *         in="query",
     *         description="活动分类ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getPartyNormalList()
    {
        $key = $this->key;
        $party_category_id = $this->party_category_id;
        $data = [
            'key' => $key,
            'party_category_id' => $party_category_id
        ];
        $response = PartyLogic::getPartyNormalList($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/party/detail",
     *     tags={"Party"},
     *     description="获取某个活动的详情",
     *     operationId="getPartyDetail",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥，用户登录状态下需要传loginSession",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="party_id",
     *         in="query",
     *         description="活动ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getPartyDetail()
    {
        $party_id = $this->party_id;
        $loginSession = $this->loginSession;
        $data = [
            'loginSession' => $loginSession,
            'party_id' => $party_id
        ];
        $response = PartyLogic::getPartyDetail($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Post(
     *     path="/party/delete",
     *     tags={"Party"},
     *     description="删除活动",
     *     operationId="deleteParty",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥，用户登录状态下需要传loginSession",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="party_id",
     *         in="query",
     *         description="活动ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function deleteParty()
    {
        $party_id = $this->party_id;
        $data = [
            'party_id' => $party_id
        ];
        $response = PartyLogic::deleteParty($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }
}